/**
 * 重新发送邮件
 * @param $scope
 * @param $state
 * @param $cookies
 */
module.exports = function ($rootScope,$scope, $state, $cookies, $window, $stateParams, emailrightService) {

    // $scope.email = '';
    // $scope.email = $stateParams.email;
    /*获取邮件地址*/
    $scope.email = kbt.decrypt($cookies.get('personageEmail'));

    $('.userEmail').html($scope.email);

  $('#teee').hide()
    /**
     * 重新发送邮箱
     */
    $scope.resendEmail = function () {
        $rootScope.loadingShow = true;
        $rootScope.fadeShow = true;

        if ($scope.email == null || $scope.email == undefined || $scope.email == "") {
            alert("重新发送出错，请退出重试");
            $rootScope.loadingShow = false;
            $rootScope.fadeShow = false;
        } else {
            emailrightService.resendEmailUrl($scope.email).then(function (response) {
                $rootScope.loadingShow = false;
                $rootScope.fadeShow = false;
                //请求成功
                if (response.code == 1) {
                    //alert("发送邮件成功，请注意查收邮件");
                  $('#teee').show()
                } else {
                    alert(response.msg);
                }
            }, function (response) {
                $rootScope.loadingShow = false;
                $rootScope.fadeShow = false;
                console.error('resendEmail error', response.status, response.statusText);
            });
        }
    };

    // 去邮箱验证
    $scope.gotoEmailUrl = function(){
        var emailUrl = "http://mail." + $scope.email.substr($scope.email.indexOf("@") + 1, $scope.email.length);
        $window.location.href  = emailUrl;
    }

    // 重新注册
    $scope.reRegister = function(){
        $state.go("loginHeader.register");
    }

};
